package com.aierjun.ani.init;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

/**
 * Created by Ani_aierJun on 2017/9/29.
 */

public class GlideUtils {
    /*
    *  加载本地图片  File file = new File(getExternalCacheDir() + "/image.jpg");
    *  加载应用资源  int resource = R.drawable.image;
    *  加载二进制流  byte[] image = getImageBytes();
    *  加载Uri对象   Uri imageUri = getImageUri();
    *
    * */
    public static void load(Context context, String path, ImageView imageView) {
        Glide.with(context).load(path).into(imageView);
    }

    /*
    * 加载占位图
    * */
    public static void loadAddPlaceholder(Context context, String path, int resourceId, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .placeholder(resourceId)
                .into(imageView);
    }

    /*
   * 加载占位图
   * */
    public static void loadAddPlaceholder(Context context, String path, Drawable drawable, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .placeholder(drawable)
                .into(imageView);
    }

    /*
  * 不缓存图片
  * */
    public static void loadAddPlaceholderNoneCache(Context context, String path, int resourceId, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .placeholder(resourceId)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .into(imageView);
    }

    /*
 * 不缓存图片
 * */
    public static void loadAddPlaceholderNoneCache(Context context, String path, Drawable drawable, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .placeholder(drawable)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .into(imageView);
    }

    /*
    * 不缓存
    * 添加占位图
    * 添加失败图
    * */
    public static void loadAddPlaceholderAddErrorNoneCache(Context context, String path, int resourceIdPlaceholder, int resourceIdError, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .into(imageView);
    }

    /*
    * 不缓存
    * 添加占位图
    * 添加失败图
    * */
    public static void loadAddPlaceholderAddErrorNoneCache(Context context, String path, Drawable resourceIdPlaceholder, Drawable resourceIdError, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .into(imageView);
    }

    /*
    * 缓存
    * 添加占位图
    * 添加失败图
    * */
    public static void loadAddPlaceholderAddError(Context context, String path, int resourceIdPlaceholder, int resourceIdError, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .into(imageView);
    }

    /*
   * 缓存
   * 添加占位图
   * 添加失败图
   * */
    public static void loadAddPlaceholderAddError(Context context, String path, Drawable resourceIdPlaceholder, Drawable resourceIdError, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .into(imageView);
    }

    /*
    * gif图
    * 不缓存
    * 添加占位图
    * 添加失败图
    * */
    public static void loadGifAddPlaceholderAddErrorNoneCache(Context context, String path, Drawable resourceIdPlaceholder, Drawable resourceIdError, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .asGif()
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .into(imageView);
    }

    /*
   * gif图
   * 不缓存
   * 添加占位图
   * 添加失败图
   * */
    public static void loadGifAddPlaceholderAddErrorNoneCache(Context context, String path, int resourceIdPlaceholder, int resourceIdError, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .asGif()
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .into(imageView);
    }

    /*
   * gif图
   * 缓存
   * 添加占位图
   * 添加失败图
   * */
    public static void loadGifAddPlaceholderAddError(Context context, String path, Drawable resourceIdPlaceholder, Drawable resourceIdError, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .asGif()
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .into(imageView);
    }

    /*
  * gif图
  * 缓存
  * 添加占位图
  * 添加失败图
  * */
    public static void loadGifAddPlaceholderAddError(Context context, String path, int resourceIdPlaceholder, int resourceIdError, ImageView imageView) {
        Glide.with(context)
                .load(path)
                .asGif()
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .into(imageView);
    }

    /*
   * 指定图片大小
   * 不缓存
   * 添加占位图
   * 添加失败图
   * */
    public static void loadAddPlaceholderAddErrorNoneCacheImgSize(Context context, String path, int resourceIdPlaceholder, int resourceIdError, ImageView imageView, int width, int height) {
        Glide.with(context)
                .load(path)
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .override(width, height)
                .into(imageView);
    }

    /*
   * 指定图片大小
   * 不缓存
   * 添加占位图
   * 添加失败图
   * */
    public static void loadAddPlaceholderAddErrorNoneCacheImgSize(Context context, String path, Drawable resourceIdPlaceholder, Drawable resourceIdError, ImageView imageView, int width, int height) {
        Glide.with(context)
                .load(path)
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .override(width, height)
                .into(imageView);
    }

    /*
  * 指定图片大小
  * 缓存
  * 添加占位图
  * 添加失败图
  * */
    public static void loadAddPlaceholderAddErrorImgSize(Context context, String path, Drawable resourceIdPlaceholder, Drawable resourceIdError, ImageView imageView, int width, int height) {
        Glide.with(context)
                .load(path)
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .override(width, height)
                .into(imageView);
    }

    /*
* 指定图片大小
* 缓存
* 添加占位图
* 添加失败图
* */
    public static void loadAddPlaceholderAddErrorImgSize(Context context, String path, int resourceIdPlaceholder, int resourceIdError, ImageView imageView, int width, int height) {
        Glide.with(context)
                .load(path)
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .override(width, height)
                .into(imageView);
    }

    /*
 * 指定图片大小
 * 缓存
 * gif
 * 添加占位图
 * 添加失败图
 * */
    public static void loadGifAddPlaceholderAddErrorImgSize(Context context, String path, int resourceIdPlaceholder, int resourceIdError, ImageView imageView, int width, int height) {
        Glide.with(context)
                .load(path)
                .asGif()
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .override(width, height)
                .into(imageView);
    }

    /*
 * 指定图片大小
 * gif
 * 缓存
 * 添加占位图
 * 添加失败图
 * */
    public static void loadGifAddPlaceholderAddErrorImgSize(Context context, String path, Drawable resourceIdPlaceholder, Drawable resourceIdError, ImageView imageView, int width, int height) {
        Glide.with(context)
                .load(path)
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .override(width, height)
                .into(imageView);
    }

    /*
* 指定图片大小
* gif
* 不缓存
* 添加占位图
* 添加失败图
* */
    public static void loadGifAddPlaceholderAddErrorNoneCacheImgSize(Context context, String path, int resourceIdPlaceholder, int resourceIdError, ImageView imageView, int width, int height) {
        Glide.with(context)
                .load(path)
                .asGif()
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .override(width, height)
                .into(imageView);
    }

    /*
* 指定图片大小
* gif
* 不缓存
* 添加占位图
* 添加失败图
* */
    public static void loadGifAddPlaceholderAddErrorNoneCacheImgSize(Context context, String path, Drawable resourceIdPlaceholder, Drawable resourceIdError, ImageView imageView, int width, int height) {
        Glide.with(context)
                .load(path)
                .asGif()
                .placeholder(resourceIdPlaceholder)
                .error(resourceIdError)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .override(width, height)
                .into(imageView);
    }
}
